1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.44">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #001bb9}
16 span
.s1
{font: 18.0px Helvetica
}
17 span
.s2
{font: 9.0px Monaco
}
18 span
.s3
{color: #0024f8}
19 span
.s4
{color: #001bb9}
20 span
.s5
{color: #000000}
21 span
.Apple-tab-span
{white-space:pre
}
25 <p class=
"p1"><span class=
"s1"><b>Dbufrd
</b></span><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><b> buffer demand ugen
</b></p>
26 <p class=
"p2"><br></p>
27 <p class=
"p1">superclass: DUGen
</p>
28 <p class=
"p3"><br></p>
29 <p class=
"p3"><br></p>
30 <p class=
"p1"><b>*new(bufnum, phase, loop)
</b></p>
31 <p class=
"p3"><br></p>
32 <p class=
"p1">all inputs can be either demand ugen or any other ugen.
</p>
33 <p class=
"p3"><br></p>
34 <p class=
"p1"><b>bufnum
</b><span class=
"Apple-tab-span"> </span>buffer number to read from
</p>
35 <p class=
"p1"><b>phase
</b><span class=
"Apple-tab-span"> </span>index into the buffer
</p>
36 <p class=
"p1"><b>loop
</b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>when phase exceeds number of frames in buffer, loops when set to
1 (default :
1)
</p>
37 <p class=
"p3"><br></p>
38 <p class=
"p1">see also [
<a href=
"Dbufwr.html"><span class=
"s3">Dbufwr
</span></a>]
<span class=
"Apple-tab-span"> </span></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p2"><br></p>
41 <p class=
"p4">// example
</p>
42 <p class=
"p2"><br></p>
43 <p class=
"p5">b =
<span class=
"s4">Buffer
</span>.alloc(s,
24,
1);
</p>
44 <p class=
"p5">b.setn(
0, { exprand(
200,
500) } ! b.numFrames);
</p>
45 <p class=
"p5">b.getn(
0, b.numFrames, {
<span class=
"s4">|x|
</span> x.postln })
</p>
46 <p class=
"p2"><br></p>
48 <p class=
"p5">{
<span class=
"s4">var
</span> indexPattern;
</p>
49 <p class=
"p5"><span class=
"Apple-tab-span"> </span>indexPattern =
<span class=
"s4">Dseq
</span>([
<span class=
"s4">Dseq
</span>([
0,
3,
5,
0,
3,
7,
0,
5,
9],
3),
<span class=
"s4">Dbrown
</span>(
0,
23,
1,
5)],
<span class=
"s4">inf
</span>);
</p>
50 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>SinOsc
<span class=
"s5">.ar(
</span></p>
51 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Demand
</span>.kr(
<span class=
"s4">Dust
</span>.kr(
10),
0,
<span class=
"s4">Dbufrd
</span>(b, indexPattern))
</p>
52 <p class=
"p5"><span class=
"Apple-tab-span"> </span>) *
0.1</p>
53 <p class=
"p5">}.play;
</p>
55 <p class=
"p2"><br></p>
56 <p class=
"p4">// buffer as a time pattern
</p>
57 <p class=
"p2"><br></p>
58 <p class=
"p5">c =
<span class=
"s4">Buffer
</span>.alloc(s,
24,
1);
</p>
59 <p class=
"p5">c.setn(
0, { [
1,
0.5,
0.25].choose } ! c.numFrames);
</p>
60 <p class=
"p5">c.getn(
0, c.numFrames, {
<span class=
"s4">|x|
</span> x.postln })
</p>
61 <p class=
"p2"><br></p>
63 <p class=
"p5">{
<span class=
"s4">var
</span> indexPattern;
</p>
64 <p class=
"p5"><span class=
"Apple-tab-span"> </span>indexPattern =
<span class=
"s4">Dseq
</span>([
<span class=
"s4">Dseq
</span>([
0,
3,
5,
0,
3,
7,
0,
5,
9],
3),
<span class=
"s4">Dbrown
</span>(
0,
23,
1,
5)],
<span class=
"s4">inf
</span>);
</p>
65 <p class=
"p6"><span class=
"s5"><span class=
"Apple-tab-span"> </span></span>SinOsc
<span class=
"s5">.ar(
</span></p>
66 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Duty
</span>.kr(
</p>
67 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dbufrd
</span>(c,
<span class=
"s4">Dseries
</span>(
0,
1,
<span class=
"s4">inf
</span>)) *
0.5,
<span class=
"Apple-converted-space"> </span></p>
68 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
<span class=
"Apple-converted-space"> </span></p>
69 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">Dbufrd
</span>(b, indexPattern)
</p>
70 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
71 <p class=
"p5"><span class=
"Apple-tab-span"> </span>) *
0.1</p>
72 <p class=
"p5">}.play;
</p>
74 <p class=
"p2"><br></p>
75 <p class=
"p4">// free buffers
</p>
76 <p class=
"p2"><br></p>
77 <p class=
"p5">b.free; c.free;
</p>
78 <p class=
"p2"><br></p>
79 <p class=
"p2"><br></p>
80 <p class=
"p2"><br></p>